package com.javatest;

/**
 * @author LL
 *打印矩形、菱形、三角形
 * @create 2020-12-10 16:19
 */
public class Subject13 {

    //矩形
    public static void rectangle(){
        for (int i = 0; i < 10; i++) {
            for (int j = 5; j < 10; j++) {
                System.out.print("*");
            }
            System.out.println("");
        }
    }

    //菱形
    public static void diamond(){
        for (int i = 1; i <= 6 ; i++) {
            for (int j = 6; j >= i; j--) {
                System.out.print(" ");
            }
            for (int j = 1; j <= i ; j++) {
                System.out.print("*");
            }
            for (int j = 1; j < i; j++) {
                System.out.print("*");
            }
            System.out.println("");
        }
        for (int i = 1; i <= 5 ; i++) {
            for (int j = 0; j <= i ; j++) {
                System.out.print(" ");
            }
            for (int j = 5; j >= i; j--) {
                System.out.print("*");
            }
            for (int j = 5; j > i; j--) {
                System.out.print("*");
            }
            System.out.println("");
        }
    }

    //三角形
    public static void triangle(){
        int size=5;
        for (int i = 1; i <= size; i++) {
            for (int j = 1; j <= size - i; j++) {
                System.out.print(" ");
            }
            for (int k = 1; k <= 2 * i - 1; k++) {
                System.out.print('*');
            }
            System.out.println();
        }
//        for (int i = 1; i <= size-1; i++) {
//            for (int j = 1; j <= i; j++){
//                System.out.print(" ");
//            }
//            for (int k = 2*size-3; k >= 2 * i - 1; k--){
//                System.out.print('*');
//            }
//            System.out.println();
//        }
    }


    public static void main(String[] args) {
        //rectangle();//矩形
        diamond();
        triangle();


    }

}
